package com.nbsaas.boot.wms.data.entity;

import com.nbsaas.boot.code.annotation.CatalogClass;
import com.nbsaas.boot.code.annotation.FieldConvert;
import com.nbsaas.boot.code.annotation.FieldName;
import com.nbsaas.boot.code.annotation.FormAnnotation;
import com.nbsaas.boot.jpa.data.entity.CatalogEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;


@CatalogClass
@EqualsAndHashCode(callSuper = true)
@Data
@FormAnnotation(title = "仓库", model = "仓库")
@Entity
@Table(name = "nb_wms_warehouse_catalog")
public class WarehouseCatalog extends CatalogEntity {

    @FieldConvert
    @FieldName
    @ManyToOne(fetch = FetchType.LAZY)
    private WarehouseCatalog parent;

    @Override
    public Serializable getParentId() {
        if (parent != null) {
            return parent.getId();
        }
        return null;
    }
}
